package com.apes.scm.masterdata.party.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：当事人身份标识
 *
 * @author xul
 * @create 2018-01-23 13:48
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PartyIdentification.CONST_TABLE_NAME, indexes = {
        @Index(name = "idx_mas_Identification_value", columnList = "PARTY_ID_TYPE,ID_VALUE", unique = true),
        @Index(name = "idx_Identification_party_id", columnList = "PARTY_ID")
})
public class PartyIdentification extends BaseModel {
    public static final String CONST_TABLE_NAME = "mas_party_Identification";

    @Id
    @Column(name = "ID")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "当事人身份标识")
    private long id;

    @Column(name = "PARTY_ID_TYPE", length = 20)
    private String partyIdType; //标识类型（'idCard':身份证; 'mobile':手机; 'weixin':微信; 'taxNumber':税号; 'businessLicense':营业执照）

    @Column(name = "ID_VALUE", length = 30)
    private String idValue; //标识类型值

    @ManyToOne(optional = false)
    @JoinColumn(name="PARTY_ID", referencedColumnName="ID", nullable = false)
    private Party party;

    @Column(name = "SOURCE_ID", length = 20)
    private String sourceId; //来源ID

    @Column(name = "EXT_ID", length = 30)
    private String extId; //外部ID

}
